package com.puff.mapper;

import com.github.pagehelper.Page;
import com.puff.annotation.AutoFill;
import com.puff.dto.ShopListDTO;
import com.puff.dto.ShopPageQueryDTO;
import com.puff.entity.Shop;
import com.puff.entity.ShopCategory;
import com.puff.enumeration.OperationType;
import com.puff.vo.ShopVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShopMapper {

    /**
     * 平台端商家分页查询
     * @param shopPageQueryDTO
     * @return
     */
    Page<ShopVO> pageQuery(ShopPageQueryDTO shopPageQueryDTO);

    /**
     * 向商家表中插入一条数据
     * @param shop
     */
    @AutoFill(OperationType.INSERT)
    void insert(Shop shop);

    /**
     * 根据主键id查询数据
     * @param id
     * @return
     */
    @Select("select * from shop where id = #{id}")
    Shop getById(Long id);

    /**
     * 根据主键id批量删除数据
     * @param ids
     */
    void deleteByIds(List<Long> ids);

    /**
     * 动态修改商家信息
     * @param shop
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Shop shop);

    /**
     * 根据商家分类ID查询数据
     * @param shopCategoryId
     * @return
     */
    @Select("select * from shop where shop_category_id = #{shopCategoryId}")
    Shop getByShopCategoryId(Long shopCategoryId);

    /**
     * 用户端商家查询
     * @param shopListDTO
     * @return
     */
    List<ShopVO> list(ShopListDTO shopListDTO);
}
